package yki.paperplane.server.db.planeoperator;

import java.net.URI;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import yki.paperplane.server.db.DBOperator;

public class GetThePlaneOperator extends DBOperator{

	int user_id;
	Date date;
	
	public GetThePlaneOperator( int user_id, Date date ){
		this.user_id = user_id;
		this.date = date;
	}
	
	@Override
	public Integer execute(Connection connection) throws SQLException {
		PreparedStatement statement = connection.prepareStatement( SQL_GETTHEPLANE);
		statement.setInt(1, user_id);
		statement.setDate(2, date);
		ResultSet resultSet = statement.executeQuery();
		if( resultSet.first() ){
			return resultSet.getInt(1);
		}else {
			return -1;
		}
	}

}
